package com.eco.fanliapp.admin.controller.web;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eco.fanliapp.admin.common.BaseController;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.entity.SysLog;
import com.eco.fanliapp.service.ISysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("web/sysLog")
public class SysLogController extends BaseController {

    @Autowired
    private ISysLogService iSysLogService;


    @GetMapping("getAdminLog")
    public ServerResponse getAdminLog(@RequestParam(defaultValue = "0") Integer pageNum, @RequestParam(defaultValue = "20") Integer pageSize) {

        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("log_type", 1);
        queryWrapper.orderByDesc("creat_time");
        Page<SysLog> page = new Page<>(pageNum, pageSize);
        IPage iPage = iSysLogService.page(page, queryWrapper);
        return ServerResponse.createBySuccess("查询成功", iPage);
    }
}
